load(
    "//tools:defaults.bzl",
    "extract_tokens",
    "markdown_to_html",
    "ng_project",
    "sass_binary",
    "sass_library",
)

package(default_visibility = ["//visibility:public"])

sass_library(
    name = "m3",
    srcs = [
        "_m3-form-field.scss",
    ],
    deps = [
        "//src/material/core/style:sass_utils",
        "//src/material/core/tokens:m3_utils",
    ],
)

sass_library(
    name = "m2",
    srcs = [
        "_m2-form-field.scss",
    ],
    deps = [
        "//src/material/core/style:elevation",
        "//src/material/core/style:sass_utils",
        "//src/material/core/theming:_inspection",
        "//src/material/core/tokens:m2_utils",
    ],
)

sass_library(
    name = "theme",
    srcs = [
        "_form-field-theme.scss",
    ],
    deps = [
        ":m2",
        "//src/material/core/style:sass_utils",
        "//src/material/core/theming",
        "//src/material/core/theming:_inspection",
        "//src/material/core/theming:_validation",
        "//src/material/core/tokens:token_utils",
        "//src/material/core/typography",
    ],
)

sass_binary(
    name = "css",
    src = "form-field.scss",
    deps = [
        ":form_field_partials",
        "//src/material/core/style:vendor_prefixes",
        "//src/material/core/tokens:token_utils",
    ],
)

sass_library(
    name = "form_field_scss_lib",
    srcs = [
        "_form-field-theme.scss",
    ],
    deps = [
        "//src/material/core/style:sass_utils",
        "//src/material/core/theming",
        "//src/material/core/theming:_inspection",
        "//src/material/core/theming:_validation",
        "//src/material/core/tokens:token_utils",
        "//src/material/core/typography",
    ],
)

sass_library(
    name = "form_field_partials",
    srcs = [
        "_form-field-focus-overlay.scss",
        "_form-field-high-contrast.scss",
        "_form-field-native-select.scss",
        "_form-field-subscript.scss",
        "_mdc-text-field-density-overrides.scss",
        "_mdc-text-field-structure.scss",
        "_mdc-text-field-structure-overrides.scss",
        "_mdc-text-field-textarea-overrides.scss",
        "_user-agent-overrides.scss",
    ],
    deps = [
        "//src/cdk:sass_lib",
        "//src/material/core/style:layout_common",
        "//src/material/core/style:vendor_prefixes",
        "//src/material/core/tokens:token_utils",
    ],
)

ng_project(
    name = "form-field",
    srcs = [
        "form-field.ts",
        "form-field-control.ts",
        "form-field-errors.ts",
        "form-field-module.ts",
        "index.ts",
        "public-api.ts",
    ],
    assets = [
        "form-field.html",
        ":css",
    ],
    deps = [
        "//:node_modules/@angular/common",
        "//:node_modules/@angular/core",
        "//:node_modules/@angular/forms",
        "//:node_modules/rxjs",
        "//src:dev_mode_types",
        "//src/material/core",
        "//src/material/form-field/directives",
    ],
)

markdown_to_html(
    name = "overview",
    srcs = [":form-field.md"],
)

extract_tokens(
    name = "tokens",
    srcs = [":theme"],
)

filegroup(
    name = "source-files",
    srcs = glob(["**/*.ts"]),
)
